<?php

/**
 * 逻辑区：轮播广告相关
 * @copyright (C)2011 Cenwor Inc.
 * @author fengwei
 * @package logic
 * @name lunboad.logic.php
 * @version 1.0
 */

class LunboadLogic
{
	
	public function GetOne($id)
	{
		$sql = 'SELECT * from  '.table('lbad').' ad_id='.$id;
		$info = dbc()->Query($sql)->GetRow();
		/* if( $info['end_time'] < time()){
			$info['status'] = 0;
		} */
		return $info;
	}
	
	public function Add($ad_img,$ad_link,$city_id,$ad_text='',$sort=0 )
	{

		$data = array(
				

				'ad_img' => $ad_img,
				'ad_link' => $ad_link,
				'city_id' => $city_id,
				'sort'=>$sort,
		);
		if ($ad_text) {
			$data['ad_text']=$ad_text;
		}
		dbc()->SetTable(table('lbad'));
		return dbc()->Insert($data);
	}
	
	public function Add_wap($ad_img,$ad_link,$city_id,$ad_text='',$sort=0 )
	{
	
		$data = array(
	
	
				'ad_img' => $ad_img,
				'ad_link' => $ad_link,
				'city_id' => $city_id,
				'sort'=>$sort,
		);
		if ($ad_text) {
			$data['ad_text']=$ad_text;
		}
		dbc()->SetTable(table('wap_lbad'));
		return dbc()->Insert($data);
	}
	
	
	 public function GetList()
	{
		$city_id = logic('misc')->City('id');
		
		$sql_limit_city = '1';
		if ($city_id > 0)
		{
			$sql_limit_user = ' city_id = '.$city_id;
		}
		$sql = 'SELECT * from  '.table('lbad').' WHERE'.$sql_limit_user.' ORDER BY sort limit 5';
		

		$lbad_list = dbc(DBCMax)->query($sql)->done();
		
		include handler('template')->file('@html/lbad/list');
		//include handler('template')->file('lbad_list');

		
	} 
	
	public function Wap_getList()
	{
		$city_id = logic('misc')->City('id');
	
		$sql_limit_city = '1';
		if ($city_id > 0)
		{
			$sql_limit_user = ' city_id = '.$city_id;
		}
		$sql = 'SELECT * from  '.table('wap_lbad').' WHERE'.$sql_limit_user.' ORDER BY sort limit 3';
	
	
		$lbad_list = dbc(DBCMax)->query($sql)->done();
	
		include handler('template')->file('wap_lbad_list');
		//include handler('template')->file('lbad_list');
	
	
	}
	
	/* public function SrcOne($id)
	{
		$result = dbc(DBCMax)->select('ad')->where('ad_id='.$id)->done();
		return $result[0];
	}
	
	public function SrcList($city_id=0)
	{
		$sql_limit_city = '1';
		if ($city_id > 0)
		{
			$sql_limit_user = ' city_id = '.$city_id;
		}
		$sql = 'SELECT * from  '.table('ad').' WHERE'.$sql_limit_user.' ORDER BY sort';
		
		logic('isearcher')->Linker($sql);
		//$sql = page_moyo($sql);
		return dbc(DBCMax)->query($sql)->done();
		
	} */
	
	
}
?>